function render(currentUser, albumDO, trackDOList) {
    document.querySelector('.album').textContent += albumDO.aid + " " + albumDO.title
    var tbody = document.querySelector('tbody')
    for (var i in trackDOList) {
        var trackDO = trackDOList[i]
        var html = `<tr><td>${trackDO.tid}</td><td>${trackDO.title}</td></tr>`
        tbody.innerHTML += html
    }
}


window.onload = function () {
    var xhr = new XMLHttpRequest()
    xhr.open("get", "/studio/album/album.json" + location.search)
    xhr.onload = function () {
        if (xhr.status !== 200) {
            alert("数据获取错误，请稍后重试")
            return
        }
        console.log(this.responseText)
        var data = JSON.parse(this.responseText)
        if (!data.currentUser) {
            alert("用户未登录")
            location("/studio/user/login.html")
            return
        }
        document.querySelector('.add').href += `?aid=${data.albumDO.aid}`
        render(data.currentUser, data.albumDO, data.trackDOList)
    }
    xhr.send()
}